<%@ Application Language="VB" %>

<script runat="server">

    Dim timer As Timers.Timer
    
    Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs on application startup
        timer = New Timers.Timer(5000)
        timer.AutoReset = False
        timer.Enabled = True
        AddHandler timer.Elapsed, AddressOf RefreshFeeds
    End Sub
    
    Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs on application shutdown
        timer.Enabled = False
    End Sub
        
    Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs when an unhandled error occurs
    End Sub

    Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs when a new session is started
    End Sub

    Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs when a session ends. 
        ' Note: The Session_End event is raised only when the sessionstate mode
        ' is set to InProc in the Web.config file. If session mode is set to StateServer 
        ' or SQLServer, the event is not raised.
    End Sub
    
    Sub RefreshFeeds(ByVal sender As Object, ByVal eventargs As System.Timers.ElapsedEventArgs)
        If Not Application("inUse") = "true" Then
            Application("inUse") = "true"
            Try
                GLShared.UpdateFeeds()
            Finally
                timer.Interval = 300000
                timer.Enabled = True
                Application("inUse") = "false"
            End Try
        End If
    End Sub
       
</script>